
public class Player 
{

	/**
	 * @param args
	 */
	public static void main(String[] args) 
	{
		if (args.length <3)
		{
			System.out.println("Incorrect use\nIf startiing the first player\n" +
					"java Player <Is it a Main Server (1)> " +
					"<GridSize> <NoOfTreasures> <Port Number>" +
					"\nThe Port number is optional.\n" +
					"If starting another player" +
					"java Player <Is it a Main Server (0)> " +
					"<Port of the server> <IP Address of the server> <Port to start Player server>\n" +
					"The Port to start Player server is optional");
			System.exit(0);
		}
		
		boolean mainServer = false;
		
		int gridSize = 0;
		int noOfTreasures = 0;
		int port = -1;
		String host = null;
		int myPort = -1;
		if (Integer.parseInt(args[0]) == 1)
		{
			mainServer = true;
			gridSize = Integer.parseInt(args[1]);
			noOfTreasures = Integer.parseInt(args[2]);
			if (args.length >3)
				port = Integer.parseInt(args[3]);
			
		}
		else 
		{
			port = Integer.parseInt(args[1]);
			host = args[2];
			if (args.length == 4)
				myPort = Integer.parseInt(args[3]);
		}
		
		Server obj = null;
		
		if (mainServer)
		{
			obj = new Server(gridSize, noOfTreasures, port);
			Server.start(obj);
		}
		Client.start(port, host, mainServer, myPort);
	
	// TODO Auto-generated method stub
	}
}
